import { Alert, Image } from '@aws-amplify/ui-react'; import { ComponentStyleDisplay } from '@/components/ComponentStyleDisplay'; import { Example, ExampleCode } from '@/components/Example'; import { Fragment } from '@/components/Fragment'; import { AppDirectoryAlert } from '@/components/AppDirectoryAlert'; import { InstallScripts } from '@/components/InstallScripts'; import ReactPropsTable from '@/components/propsTable/ReactPropsTable'; import { STORAGE_IMAGE } from './props'; import { DefaultStorageImageExample, StorageImageErrorHandlingExample } from './examples' ## Basic Usage Did you follow the [quick start instructions](/connected-components/storage#quick-start) to set up the storage and auth services? {({ platform }) => import('@/components/AppDirectoryAlert')} To use the StorageImage component, import it into your React application with the included styles. ```js import { StorageImage } from '@aws-amplify/ui-react-storage'; import '@aws-amplify/ui-react/styles.css'; ``` At a minimum you must include the `alt`, `imgKey` and `accessLevel` props. `accessLevel` refers to the [Amplify Storage access level](https://docs.amplify.aws/lib/storage/configureaccess/q/platform/js/), which is `'public' | 'private' | 'protected'`. cat ```jsx file=./examples/DefaultStorageImageExample.tsx ``` ## Props Note: A new `Storage.get` request is made only when the `imgKey` changes. ## Error Handling To handle the error caused by `Storage.get`, you can pass a `onStorageGetError` handler and optionally provide a `fallbackSrc` for the component to load a fallback image. fallback cat ```jsx file=./examples/StorageImageErrorHandlingExample.tsx ``` ## Customization ### Target Classes